#pragma once
//各种工具函数接口
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <boost/algorithm/string.hpp>
#include "cppjieba/Jieba.hpp"

using namespace std;
namespace ns_gongjv{
    //读取指定文件所有内容
    class Filegongjv{
        public:
        static bool ReadFile(const std::string &file_path,std::string *out)
        {
            std::ifstream in(file_path,std::ios::in);//读取文件内容
            if(!in.is_open()){
                std::cerr<<"open file"<<file_path<<"error"<<std::endl;
            }
            std::string line;
            while(std::getline(in,line))
            {
                *out+=line;
            }
            in.close();
            return true;
        }

    };

    //词库
     const char* const DICT_PATH = "./dict/jieba.dict.utf8";
    const char* const HMM_PATH = "./dict/hmm_model.utf8";
    const char* const USER_DICT_PATH = "./dict/user.dict.utf8";
    const char* const IDF_PATH = "./dict/idf.utf8";
    const char* const STOP_WORD_PATH = "./dict/stop_words.utf8";

   //分割输入字符串
    class StringSplit{
        public:
        static void Split(const string input,vector<string> *out, const string &sep)
        {
            //最后一个参数作用默认为boost::token_compress_off（关闭），开启后作用为压缩分割符号
            //例如：\3\3\3\3  -》》\3
            boost::split(*out,input,boost::is_any_of(sep),boost::token_compress_on);

        }
    };
    //分词工具
    class Jiebagongjv{
       private:
       static cppjieba::Jieba jieba;
        
        public:
        static void CutString(const std::string &src, std::vector<std::string> *out)
            {
                jieba.CutForSearch(src, *out);
            }
        
    };
    cppjieba::Jieba Jiebagongjv::jieba(DICT_PATH, HMM_PATH, USER_DICT_PATH, IDF_PATH, STOP_WORD_PATH);

}